package demo1;

import java.util.Scanner;

public class MoviesOperator
{
    private Movie movies[];
    int i = 0;

    public MoviesOperator(Movie movies[]) {
        this.movies = movies;
    }

    public void moviesPrint() {
        for (i = 0; i < movies.length; i++) {
            Movie m = movies[i];
            System.out.println(m.getId() + "\t" + m.getName() + "\t" +
                    "\t" + m.getScore() + "\t" + m.getActor());
        }
    }
        public void moviesSearch()
    {
            int id = 0;
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入要查询的id");
            id = sc.nextInt();
            for (i = 0; i < movies.length; i++)
            {
            Movie m = movies[i];
            if(m.getId()== id)
                {
                System.out.println(m.getId()+"\t"+m.getName()+"\t"+
                        m.getScore()+"\t"+m.getActor());
                return;
                }
            }
            System.out.println("没有找到该id");
    }
}
